package cn.imu.appdevexperiment2020._1activity;

import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.util.Log;
import android.widget.EditText;
import android.widget.TextView;

import androidx.annotation.Nullable;
import androidx.appcompat.app.AppCompatActivity;

import butterknife.BindView;
import butterknife.OnClick;
import cn.imu.appdevexperiment2020.R;
import cn.imu.appdevexperiment2020.cch.util.ToastUtil;
import cn.imu.appdevexperiment2020.common.BaseActivity;

/**
 * 描述:
 *
 * @author chenconghua
 * @version 1.0
 * @create 2022-10-26 15:58
 */
public class IntentActivity  extends BaseActivity {

    private static final String TAG="ButterKnifeTestActivity";
    @BindView(R.id.edt1)
    EditText editText1;
    @BindView(R.id.edt2)
    EditText editText2;
    @BindView(R.id.tv_intent_1)
    TextView textView1;
    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_intent);
        init();
    }

    @Override
    protected void onActivityResult(int requestCode, int resultCode, @Nullable Intent data) {
        super.onActivityResult(requestCode, resultCode, data);
       switch (requestCode){
           case 1:
               if (resultCode==RESULT_OK){
                   String retuenData=data.getStringExtra("data_return");
                   textView1.setText(retuenData);
               }
       }
    }

    private void init() {

    }

    @OnClick(R.id.btn1)
    public void btn1(){
        Intent intent =new Intent(IntentActivity.this,FirstActivity.class);
        intent.putExtra("extra_data",editText1.getText().toString());
        startActivity(intent);
    }
    @OnClick(R.id.btn2)
    public void btn2(){
        Intent intent =new Intent(IntentActivity.this,FirstActivity.class);
        intent.putExtra("extra_data",editText2.getText().toString());
        intent.putExtra("flag","btn2result");
        startActivityForResult(intent,1);
        Log.e(TAG,"btn2");
    }
    @OnClick(R.id.btn3)
    public void btn3(){
        Intent intent = new Intent("cn.imu.appdevexperiment2020._1activity.ACTION_START" );
        intent.addCategory("cc");
        startActivity(intent);
        Log.e(TAG,"btn3");
    }
    @OnClick(R.id.btn4)
    public void btn4(){
        Intent intent = new Intent(IntentActivity.this,LifeCycleActivity.class );
        startActivity(intent);
        Log.e(TAG,"btn4");
    }
    @OnClick(R.id.btn5)
    public void btn5(){
        Intent intent = new Intent(IntentActivity.this,ThirdActivity.class );
        startActivity(intent);
        Log.e(TAG,"btn5");
    }
    @OnClick(R.id.btn6)
    public void btn6(){
        Intent intent = new Intent(IntentActivity.this,FourActivity.class );
        startActivity(intent);

        Log.e(TAG,"btn6");
    }
    @OnClick(R.id.btn7)
    public void btn7(){

        FiveActivity.actionStart(IntentActivity.this,"data1","data2");
//        IntentActivity.actionStart();
        Log.e(TAG,"btn7");
    }




}
